﻿<Window x:Class="WPFXMPPClient.BrowserPopupWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib" 
        xmlns:location="clr-namespace:LocationClasses;assembly=LocationClasses"
        xmlns:comp="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:local="clr-namespace:WPFXMPPClient"
        AllowsTransparency="False" WindowStyle="None"
        MouseDown="Window_MouseDown"  ResizeMode="CanResizeWithGrip" Loaded="Window_Loaded" Width="911" Height="919"
        Title="Buddy Map">

    <Window.Resources>
        <CollectionViewSource x:Key="SortedRosterItems" x:Name="OurSortedRosterCollection">
            <CollectionViewSource.SortDescriptions>
                <comp:SortDescription PropertyName="Name" />
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Group" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
        <ObjectDataProvider x:Key="mapProviderTypeData"
                    MethodName="GetValues" 
                    ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="location:MapProviderType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider x:Key="mapTypeData"
                    MethodName="GetValues" 
                    ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="location:MapType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFBBFF81" Offset="0"/>
            <GradientStop Color="#FFEEFFDF" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>


    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" >

        <Grid x:Name="LayoutRoot" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>



            <Border Grid.Row="0"  BorderThickness="1">
                <Border.BorderBrush >
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="Gray" Offset="1"/>
                    </LinearGradientBrush>
                </Border.BorderBrush>
            </Border>

            <Grid Margin="0,5" Grid.Row="0" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="357*" />
                    <ColumnDefinition Width="40" />
                    <ColumnDefinition Width="40" />
                    <ColumnDefinition Width="40" />
                    <ColumnDefinition Width="40" />
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="TextBoxTitle" Grid.ColumnSpan="5" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="Bold" Text="Buddy Map"></TextBlock>
                <!--<s:SurfaceButton ToolTip="Save" IsEnabled="{Binding bDirty}" Grid.Column="1" x:Name="ButtonSave" Click="ButtonSave_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                    <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" />
                </s:SurfaceButton>-->
                <Button Style="{DynamicResource ButtonSurface}" Visibility="Visible" ToolTip="Refresh" Grid.Column="2" x:Name="ButtonRefresh" Click="ButtonRefresh_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                    <Image Source="Images/refresh.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" />
                </Button>
                <Button Grid.Column="3" Style="{DynamicResource ButtonSurface}" ToolTip="Minimize" x:Name="ButtonMinimize" Click="ButtonMinimize_Click"  HorizontalAlignment="Center" Padding="0" VerticalAlignment="Bottom" 
                                     HorizontalContentAlignment="Center" VerticalContentAlignment="Bottom">
                    <Rectangle Width="20" Height="5" Margin="0,0,0,10" Stretch="UniformToFill" Fill="#FF555555" Stroke="#FF555555" />
                </Button>
                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Close" Grid.Column="5" x:Name="ButtonClose" Click="ButtonClose_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                    <Image Source="Images/calculator - multiply.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" />
                </Button>
            </Grid>

            <ListBox Visibility="Collapsed" SelectionMode="Multiple" Grid.Row="1" Margin="3,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                 DataContext="{Binding Conversation}" Background="Beige" x:Name="ListBoxConversation">
                <ListBox.ItemTemplate>
                    <DataTemplate>

                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="70" />
                                <ColumnDefinition Width="400*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>


                        </Grid>

                    </DataTemplate>
                </ListBox.ItemTemplate>

            </ListBox>



            <Grid Grid.Row="1" Background="Transparent" Margin="3,3,3,3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding MapManager}">

                <TabControl x:Name="TabControl1" Background="Beige" Margin="3,3,3,3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">




                    <TabItem x:Name="TabItemBrowser" Header="Google Maps" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                        <Grid x:Name="GridMap">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="600*"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>


                            <Grid Name="ContentLeft" Grid.ColumnSpan="3" Grid.Row="3" Height="100" Visibility="Collapsed">
                                <Expander Header="Roster" IsExpanded="False" Visibility="Collapsed">
                                    <StackPanel>

                                        <StackPanel HorizontalAlignment="Right" Height="Auto" Orientation="Horizontal" x:Name="StackPanelRosterMenuButtons">

                                        <!--<Label HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="14" FontWeight="Bold">Roster</Label>-->
                                        <CheckBox HorizontalAlignment="Right" Margin="5,5,5,5" VerticalAlignment="Center" x:Name="CheckBoxRosterShowAll" Content="Show All" Checked="CheckBoxRosterShowAll_Checked"></CheckBox>
                                              <!--   <Button Margin="5,5,5,5" x:Name="ButtonRefreshRoster" Click="ButtonRefreshRoster_Click" Content="Refresh"></Button> -->
                                            </StackPanel>


                                    
                                    <ListView MinHeight="100" Visibility="Visible" Loaded="ListViewRosterItems_Loaded" 
                                              ItemsSource="{Binding MapManager.DictMapRosterItems.Values}"
                                              x:Name="ListViewRosterItems" SelectionChanged="ListViewRosterItems_SelectionChanged"
                                              MouseDoubleClick="ListViewRosterItems_MouseDoubleClick">

                                        <ListView.View>                                          
                                            <GridView>
                                                <GridViewColumn Width="Auto">
                                                    <GridViewColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <CheckBox x:Name="CheckBoxIsDisplayed" IsChecked="{Binding IsDisplayed, Mode=TwoWay}"
                                                                      Checked="CheckBoxIsDisplayed_Checked"></CheckBox>
                                                        </DataTemplate>
                                                    </GridViewColumn.CellTemplate>
                                                </GridViewColumn>

                                                <GridViewColumn Width="Auto">
                                                    <GridViewColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <StackPanel Orientation="Horizontal">
                                                                <Image Source="{Binding RosterItem.Avatar}" Width="64" Height="64" />

                                                                <StackPanel Orientation="Vertical">
                                                                    <Label FontSize="10" VerticalAlignment="Center" FontWeight="Bold"
                                                                           Content="{Binding RosterItem.JID.BareJID}" />

                                                                    <!--  PresenceType, PresenceShow, Status -->

                                                                    <Label FontSize="8" VerticalAlignment="Center" 
                                                                           Content="{Binding RosterItem.Presence.Status}" />
                                                                    <!--<Label FontSize="8" VerticalAlignment="Center" Content="Show:     {Binding RosterItem.Presence.PresenceShow}" />
                                                <Label FontSize="8" VerticalAlignment="Center" Content="Status:   {Binding RosterItem.Presence.Status}" />-->

                                                                    <!--<Label FontSize="8" VerticalAlignment="Center" Content="{Binding RosterItem.GeoString}" />
                                                        <Label FontSize="8" VerticalAlignment="Center" Content="{Binding RosterItem.GeoLoc.TimeStamp}" />-->
                                                                </StackPanel>
                                                            </StackPanel>
                                                        </DataTemplate>
                                                    </GridViewColumn.CellTemplate>
                                                </GridViewColumn>
                                            </GridView>
                                        </ListView.View>
                                    </ListView>
                                    
                                  
                                </StackPanel>
                                </Expander>


                            </Grid>

                            <!--<local:ExtendedGridSplitter Grid.Column="1" Grid.Row="0"
                                           VerticalAlignment="Stretch"
                                           HorizontalAlignment="Center"
                                           Width="10"
                                            CollapseMode="Previous"
                                           Background="LightGray" />-->

                            <WebBrowser Grid.Row="0" Grid.Column="2" Margin="3,3,3,3" LoadCompleted="WebBrowserMain_LoadCompleted" MinWidth="400" MinHeight="400" x:Name="WebBrowserMain" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SizeChanged="WebBrowserMain_SizeChanged"></WebBrowser>

                            <!--<GridSplitter Grid.Row="1"  ResizeDirection="Rows"   
            Width="Auto" 
            Height="3"
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch" 
            Margin="0" Visibility="Visible"></GridSplitter>-->
                            <!--<Expander Grid.Row="2" Visibility="Visible" Header="Roster" >

                            </Expander>-->

                        </Grid>
                    </TabItem>
                    
                    <TabItem Header="KML" x:Name="TabItemKML" Visibility="Collapsed">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <TextBox Margin="3,3,3,3" Grid.Row="0" x:Name="TextBoxKML" AcceptsReturn="True" AcceptsTab="True" FontFamily="Courier New" AllowDrop="True"></TextBox>
                            <StackPanel Margin="3,3,3,3" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" >
                                <Button Style="{DynamicResource ButtonSurface}"  ToolTip="Load KML" x:Name="ButtonLoadKML" Click="ButtonLoadKML_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                    <TextBlock Text="Load KML" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <!--<s:SurfaceButton Width="60" ToolTip="Cancel" x:Name="ButtonCancel" Click="ButtonClose_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                <TextBlock Text="Cancel"></TextBlock>
                           
                        </s:SurfaceButton>-->
                            </StackPanel>
                        </Grid>

                    </TabItem>
 
                    <TabItem Header="Source Code" x:Name="TabItemSourceCode" Visibility="Collapsed">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="*"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid  HorizontalAlignment="Stretch" Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Label FontSize="14" Margin="3,3,3,3" x:Name="TextBoxFileName" HorizontalAlignment="Left"></Label>

                                <StackPanel Margin="3,3,3,3" Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" >
                                    <!--<s:SurfaceButton Width="60" ToolTip="Cancel" x:Name="ButtonCancel" Click="ButtonClose_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                <TextBlock Text="Cancel"></TextBlock>
                           
                        </s:SurfaceButton>-->
                                </StackPanel>
                                <TextBox Visibility="Collapsed" Margin="6,6,559,6" AcceptsReturn="True" AcceptsTab="True" AllowDrop="True" FontFamily="Courier New" Name="TextBoxRelativePath" Text="Code/BrowserWindowSource.html" VerticalContentAlignment="Center" Width="300" />
                            </Grid>


                            <TextBox Margin="3,3,3,3" Grid.Row="1" x:Name="TextBoxBrowserSourceCode" AcceptsReturn="True" AcceptsTab="True" FontFamily="Courier New" AllowDrop="True"></TextBox>




                            <StackPanel Grid.Row="2">

                                <!--<FlowDocumentReader  Margin="3,3,3,3" Name="FlowDocReader" Background="LightBlue"

                                Height="210">

                                </FlowDocumentReader>-->
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="3,3,3,3">
                                <Label FontSize="14" VerticalAlignment="Center" FontWeight="DemiBold">JavaScript Function:</Label>
                                <TextBox VerticalContentAlignment="Center" Width="300" Margin="3,3,3,3" x:Name="TextBoxJavaScriptFunctionName" Text="moveMarker()" AcceptsReturn="True" AcceptsTab="True" FontFamily="Courier New" AllowDrop="True"></TextBox>
                                <ComboBox Visibility="Collapsed" x:Name="ComboBoxJavaScriptFunction" IsEditable="True">
                                    <ComboBoxItem>addMarker()</ComboBoxItem>
                                    <ComboBoxItem>moveMarker()</ComboBoxItem>
                                    <ComboBoxItem>centerMap()</ComboBoxItem>
                                    <ComboBoxItem>panToUser()</ComboBoxItem>
                                    <ComboBoxItem>panTo()</ComboBoxItem>
                                    <ComboBoxItem>JID()</ComboBoxItem>
                                    <ComboBoxItem>RosterItem()</ComboBoxItem>
                                    <ComboBoxItem>MapRosterItem()</ComboBoxItem>
                                </ComboBox>
                                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Reload Browser"  x:Name="ButtonCallJavaScriptFunction" Click="ButtonCallJavaScriptFunction_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                    <TextBlock Text="Invoke" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Open File" x:Name="ButtonOpenFile" Click="ButtonOpenFile_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                    <TextBlock Text="Open" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Save" x:Name="ButtonSaveFile" Click="ButtonSaveFile_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                    <TextBlock Text="Save" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Reload Browser" x:Name="ButtonLoad" Click="ButtonLoad_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                    <TextBlock Text="Load" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <!--<Button Content="Invoke Function" x:Name="ButtonCallJavaScriptFunction" Click="ButtonCallJavaScriptFunction_Click"></Button>-->
                            </StackPanel>
                        </Grid>
                    </TabItem>

                    <TabItem Visibility="Collapsed"  x:Name="TabItemMapView" Header="Map View" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                        <Grid x:Name="GridMapView">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="600*"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="0"></RowDefinition>
                                <RowDefinition Height="0"></RowDefinition>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0"></ColumnDefinition>
                                <ColumnDefinition Width="0"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>


                            <Grid Name="ContentLeftMapView" Grid.ColumnSpan="3" Grid.Row="3">

                                <StackPanel>

                                    <Label VerticalAlignment="Center" FontSize="14" FontWeight="Bold">Roster</Label>

                                    <ListView MinHeight="100" Visibility="Visible" Loaded="ListViewRosterItems_Loaded" Grid.Row="3" 
                                              ItemsSource="{Binding MapManager.DictMapRosterItems.Values}"
                                              x:Name="ListViewMapViewRosterItems" SelectionChanged="ListViewRosterItems_SelectionChanged"
                                              MouseDoubleClick="ListViewRosterItems_MouseDoubleClick">
                                        <ListView.View>
                                            <GridView>
                                                <GridViewColumn Width="20">
                                                    <GridViewColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <CheckBox x:Name="CheckBoxIsDisplayed" IsChecked="{Binding IsDisplayed, Mode=TwoWay}"
                                                                      Checked="CheckBoxIsDisplayed_Checked"></CheckBox>
                                                        </DataTemplate>
                                                    </GridViewColumn.CellTemplate>
                                                </GridViewColumn>

                                                <GridViewColumn Width="100">
                                                    <GridViewColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <StackPanel Orientation="Horizontal">
                                                                <Image Source="{Binding RosterItem.Avatar}" Width="64" Height="64" />

                                                                <StackPanel Orientation="Vertical">
                                                                    <Label FontSize="10" VerticalAlignment="Center" FontWeight="Bold" Content="{Binding RosterItem.JID.BareJID}" />

                                                                    <!--  PresenceType, PresenceShow, Status -->

                                                                    <Label FontSize="8" VerticalAlignment="Center" Content="{Binding RosterItem.Presence.Status}" />
                                                                    <!--<Label FontSize="8" VerticalAlignment="Center" Content="Show:     {Binding RosterItem.Presence.PresenceShow}" />
                                                <Label FontSize="8" VerticalAlignment="Center" Content="Status:   {Binding RosterItem.Presence.Status}" />-->

                                                                    <!--<Label FontSize="8" VerticalAlignment="Center" Content="{Binding RosterItem.GeoString}" />
                                                        <Label FontSize="8" VerticalAlignment="Center" Content="{Binding RosterItem.GeoLoc.TimeStamp}" />-->
                                                                </StackPanel>
                                                            </StackPanel>



                                                        </DataTemplate>
                                                    </GridViewColumn.CellTemplate>
                                                </GridViewColumn>

                                            </GridView>
                                        </ListView.View>

                                    </ListView>
                                    <CheckBox Margin="4,4,4,4" VerticalAlignment="Center" x:Name="CheckBoxMapViewRosterShowAll" Content="Show All" Checked="CheckBoxRosterShowAll_Checked"></CheckBox>
                                </StackPanel>



                            </Grid>

                            <!--<local:ExtendedGridSplitter Grid.Column="1" Grid.Row="0"
                                           VerticalAlignment="Stretch"
                                           HorizontalAlignment="Center"
                                           Width="10"
                                            CollapseMode="Previous"
                                           Background="LightGray" />-->

                            <WebBrowser Grid.Row="0" Grid.Column="2" Margin="3,3,3,3" LoadCompleted="WebBrowserMain_LoadCompleted" MinWidth="400" MinHeight="400" x:Name="WebBrowserMainMapView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SizeChanged="WebBrowserMain_SizeChanged"></WebBrowser>

                            <!--<GridSplitter Grid.Row="1"  ResizeDirection="Rows"   
            Width="Auto" 
            Height="3"
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch" 
            Margin="0" Visibility="Visible"></GridSplitter>-->
                            <Expander Grid.Row="2" Visibility="Visible" Header="Roster" >

                            </Expander>

                        </Grid>
                    </TabItem>

                    <TabItem Visibility="Collapsed" Header="Options">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="20"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="375*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <!--
                            //Map Parameters:

        //size (required) defines the rectangular dimensions of the map image. This parameter takes a string of the form {horizontal_value}x{vertical_value}. For example, 500x400 defines a map 500 pixels wide by 400 pixels high. Maps smaller than 180 pixels in width will display a reduced-size Google logo. This parameter is affected by the scale parameter, described below; the final output size is the product of the size and scale values.
        //scale (optional) affects the number of pixels that are returned. scale=2 returns twice as many pixels as scale=1 while retaining the same coverage area and level of detail (i.e. the contents of the map don't change). This is useful when developing for high-resolution displays, or when generating a map for printing. The default value is 1. Accepted values are 2 and 4 (4 is only available to Maps API for Business customers.) See Scale Values for more information.
        // (Default scale value is 1; accepted values are 1, 2, and (for Maps API for Business customers only) 4).

        //format (optional) defines the format of the resulting image. By default, the Static Maps API creates PNG images. There are several possible formats including GIF, JPEG and PNG types. Which format you use depends on how you intend to present the image. JPEG typically provides greater compression, while GIF and PNG provide greater detail. For more information, see Image Formats.
        //maptype (optional) defines the type of map to construct. There are several possible maptype values, including roadmap, satellite, hybrid, and terrain. For more information, see Static Maps API Maptypes below.
        //language (optional) defines the language to use for display of labels on map tiles. Note that this parameter is only supported for some country tiles; if the specific language requested is not supported for the tile set, then the default language for that tileset will be used.
        //region (optional) defines the appropriate borders to display, based on geo-political sensitivities. Accepts a region code specified as a two-character ccTLD ('top-level domain') value.

        //    The table below shows the maximum allowable values for the size parameter at each scale value.

        //API	                        scale=1	    scale=2	                                scale=4
        //Free	                        640x640	    640x640 (returns 1280x1280 pixels)	    Not available.
        //Google Maps API for Business	2048x2048	1024x1024 (returns 2048x2048 pixels)	512x512 (returns 2048x2048 pixels)
                     -->
                            <Label  Grid.Row="0" Grid.ColumnSpan="2" Content="" FontSize="20"></Label>
                            <Label Visibility="Collapsed" Grid.Row="1" Grid.ColumnSpan="2" FontSize="14" FontWeight="Bold" Content="General Options"></Label>

                            <Label Visibility="Collapsed" VerticalAlignment="Bottom" Margin="3,3,3,3" Grid.Row="2" Grid.Column="0">Map Provider</Label>
                            <ComboBox Visibility="Collapsed" HorizontalAlignment="Left" Margin="3,3,3,3" Width="200"  Grid.Row="2" Grid.Column="1" x:Name="ComboBoxMapProvider" SelectedValue="{Binding MapBuilder.MapProvider, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource mapProviderTypeData}}" SelectionChanged="ComboBoxMapProviderType_SelectionChanged"></ComboBox>


                            <Label  Grid.Row="3" Grid.ColumnSpan="2" Content="" FontSize="20"></Label>
                            <Label Grid.Row="4" Grid.ColumnSpan="2" FontSize="14" FontWeight="Bold" Content="Map Properties"></Label>

                            <Label Margin="3,3,3,3" Grid.Row="5" Grid.Column="0" VerticalAlignment="Bottom">Size</Label>
                            <StackPanel  Margin="3,3,3,3" Orientation="Horizontal" Grid.Row="5" Grid.Column="1" VerticalAlignment="Bottom">
                                <TextBox Width="80" x:Name="TextBoxSizeHorizontal" Text="{Binding MapParameters.Size.Horizontal, Mode=TwoWay}" TextChanged="TextBoxSizeHorizontal_TextChanged"></TextBox>
                                <Label>x</Label>
                                <TextBox Width="80"  x:Name="TextBoxSizeVertical" Text="{Binding MapParameters.Size.Vertical, Mode=TwoWay}" TextChanged="TextBoxSizeVertical_TextChanged"></TextBox>
                                <Label>Pixels</Label>
                            </StackPanel>

                            <Label Margin="3,3,3,3" Grid.Row="6" Grid.Column="0">Map Type</Label>
                            <ComboBox HorizontalAlignment="Left" Margin="3,3,3,3" Width="200"  Grid.Row="6" Grid.Column="1" x:Name="ComboBoxMapType" SelectedValue="{Binding MapParameters.Maptype, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource mapTypeData}}" SelectionChanged="ComboBoxMapType_SelectionChanged"></ComboBox>

                            <Label  Grid.Row="3" Grid.ColumnSpan="2" Content="" FontSize="20"></Label>
                            <Label Grid.Row="4" Grid.ColumnSpan="2" FontSize="14" FontWeight="Bold" Content="Map Properties"></Label>


                            <StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="2" HorizontalAlignment="Right">
                                <Button Style="{DynamicResource ButtonSurface}" Width="60" ToolTip="Save" IsEnabled="{Binding bDirty}" x:Name="ButtonSave" Click="ButtonSave_Click"  Height="40"  Padding="0" Margin="0,0,8,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                    <TextBlock Text="Save"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                                <Button Style="{DynamicResource ButtonSurface}" Width="60" ToolTip="Cancel" x:Name="ButtonCancel" Click="ButtonClose_Click"  Height="40"  Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                    <TextBlock Text="Cancel"></TextBlock>
                                    <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                </Button>
                            </StackPanel>

                        </Grid>
                    </TabItem>

                    <TabItem Header="Maps" Visibility="Collapsed">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="0"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="*"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Label  Grid.Row="0" Grid.ColumnSpan="2" Content="" FontSize="20"></Label>
                            <Label Grid.Row="1" Grid.ColumnSpan="2" FontSize="14" FontWeight="Bold" Content="Map Providers"></Label>

                            <Label VerticalAlignment="Top" Margin="3,3,3,3" Grid.Row="2" Grid.Column="0">Map Provider</Label>
                            <!--<ComboBox HorizontalAlignment="Left" Height="30" Margin="3,3,3,3" Width="200"  Grid.Row="2" Grid.Column="1" x:Name="ComboBoxCodeSnippets" SelectedValue="{Binding MapBuilder.MapProvider, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource mapProviderTypeData}}" SelectionChanged="ComboBoxMapProviderType_SelectionChanged"></ComboBox>-->
                            <ComboBox DisplayMemberPath="Name" HorizontalAlignment="Left" Height="30" Margin="3,3,3,3" Width="200"  Grid.Row="2" Grid.Column="1" x:Name="ComboBoxMapProvider2" SelectedValue="{Binding MapBuilder.MapProvider, Mode=TwoWay}"
                                      SelectionChanged="ComboBoxMapProviderType_SelectionChanged"></ComboBox>

                            <Label VerticalAlignment="Top" Margin="3,3,3,3" Grid.Row="3" Grid.Column="0">Code Snippets</Label>
                            <Grid Grid.Row="3" Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"></RowDefinition>
                                    <RowDefinition Height="*"></RowDefinition>
                                </Grid.RowDefinitions>

                                <ListView ItemsSource="{Binding VisibleCodeSnippets}" MinHeight="200" Margin="3,3,3,3" Grid.Row="0" x:Name="ListViewCodeSnippets" SelectionChanged="ListViewCodeSnippets_SelectionChanged" MouseDoubleClick="ListViewCodeSnippets_MouseDoubleClick">
                                    <ListView.View>
                                        <GridView>
                                            <GridViewColumn Header="API" Width="40"  >
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding ApiName}"></TextBlock>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Name" Width="200"  >
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding Name}"></TextBlock>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Source URL" Width="200"  >
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Button Style="{Binding DynamicLink}">
                                                            <Hyperlink NavigateUri="{Binding SourceURL}"></Hyperlink>
                                                        </Button>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Local File Name" Width="200"  >
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Button Style="{Binding DynamicLink}">
                                                            <Hyperlink NavigateUri="{Binding LocalFileName}"></Hyperlink>
                                                        </Button>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>



                                        </GridView>
                                    </ListView.View>
                                </ListView>

                                <!-- Details of selected item-->
                                <Grid Grid.Row="1">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"></RowDefinition>
                                        <RowDefinition Height="*"></RowDefinition>
                                    </Grid.RowDefinitions>
                         <!--           <TextBox MinHeight="200" Grid.Row="0" AcceptsReturn="True" AcceptsTab="True" Margin="3,3,3,3" x:Name="TextBoxHtml" Text="{Binding ListViewCodeSnippets.SelectedValue,Path=Html}"></TextBox> -->
                                    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">

                                        <Button Style="{DynamicResource ButtonSurface}" Width="100" ToolTip="Load HTML" IsEnabled="{Binding bDirty}" x:Name="ButtonLoadHTML" Click="ButtonLoadHTML_Click"  Height="40"  Padding="0" Margin="0,0,8,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
                                            <TextBlock Text="Load HTML"></TextBlock>
                                            <!-- <Image Source="Images/check.png" Width="30" Height="20" VerticalAlignment="Center" Margin="0" /> -->
                                        </Button>


                                    </StackPanel>

                                </Grid>
                            </Grid>
                            <!--<ComboBox HorizontalAlignment="Left" Height="30" Margin="3,3,3,3" Width="200"  Grid.Row="3" Grid.Column="1" x:Name="ComboBoxCodeSnippets" SelectedValue="{Binding MapBuilder.MapProvider, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource mapProviderTypeData}}" SelectionChanged="ComboBoxMapProviderType_SelectionChanged"></ComboBox>-->
                        </Grid>
                    </TabItem>

                    <TabItem x:Name="TabItemGoogleEarthFriends" Header="Google Earth Friends" Visibility="Collapsed">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="135" />
                                <ColumnDefinition Width="730" />
                            </Grid.ColumnDefinitions>
                            <ListView x:Name="ListViewBuddies" ItemsSource="{Binding Source={StaticResource SortedRosterItems}}" Grid.ColumnSpan="2">
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox Width="200" VerticalAlignment="Center" IsChecked="{Binding Path=ShowOnMap}" />
                                            <Label FontWeight="Bold">Name</Label>
                                            <TextBlock Width="200" VerticalAlignment="Center" Text="{Binding Path=RosterItem.JID}" />

                                            <Label FontWeight="Bold" Margin="10,0">Count</Label>
                                            <TextBlock Width="50" VerticalAlignment="Center" Text="{Binding Path=Count}" />

                                            <!--<Button Margin="10,0" x:Name="ButtonViewMap" Click="ButtonViewMap_Click">View Map</Button>-->
                                            <Button Margin="10,0" x:Name="ButtonSaveKML" Click="ButtonSaveKML_Click">Save KML</Button>

                                            <Button Margin="10,0" x:Name="ButtonClearKML" Click="ButtonClearKML_Click">Clear</Button>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>


                    </TabItem>
                </TabControl>
            </Grid>
        </Grid>

    </Border>

</Window>
